package com.itlaobing.spring.ioc.instantiating;

import java.util.Random;
import java.util.logging.Logger;

public class CarFactory {

    private static Logger logger = Logger.getLogger( CarFactory.class.getName() );

    private final String[] brands = { "秦" , "汉" , "唐" , "宋" ,  "元" , "明"  } ;
    private final Random rand = new Random();

    public CarFactory() {
        super();
        logger.info( "CarFactory()" );
    }

    // 注意这个方法是实例方法
    public Car produce() {
        logger.info( "创建Car实例" );
        Car c = new Car();
        int index = rand.nextInt( brands.length ) ;
        String b = brands[ index ] ;
        c.setBrand(  b );
        return c ;
    }

}
